home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c,comp.os.ms-windows.programmer.win32
- Path: news.inap.net!news1!ind-009-237-98
- From: dlmiller@iquest.net (Doug Miller)
- Subject: Re: How can I check whether I file exists in a multi-user environment?
- X-Nntp-Posting-Host: ind-009-237-98.iquest.net
- Message-ID: <Dp1oM8.Cns@iquest.net>
- Sender: news@iquest.net (News Admin)
- Organization: IQuest Network Services
- X-Newsreader: News Xpress Version 1.0 Beta #2.1
- References: <4jh4tl$t4c_002@chem.uva.nl>
- Date: Fri, 29 Mar 1996 19:56:33 GMT
-
- brands@chemeng.chem.uva.nl (Danny Brands) wrote:
- >Hi all,
- >
- >I need to check whether a file exists on a hard drive. Because I'm in a
- >multi-user environment I can't simply open the file. Is there another way?
- >
- >I'm using MSVC++ 2.0 / Win95.
- >
- >I'm looking in the Win32 API help file, but I can't really figure out how to
- >do it. In VB you can use the dir() command.
- >
- >Anyway, thanks in advance!
- >
- >Regards,
- >
- >Danny
- >
- * * * * C A U T I O N * * * *
- Although this will work in many implementations, to the best of my knowledge it is *NOT* ANSI C.
-
- #include <io.h>
- int file_exists (char *filename) {
- return (access(filename, 0) == 0);
- } /* returns -1 if file exists, 0 if it does not */
-